package org.hadoop.hbase;
import lombok.extern.slf4j.Slf4j;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
@Slf4j
public class ConnectTest {
    public static void main(String[] args) throws Exception {
        Configuration configuration = HBaseConfiguration.create();
        configuration.set("hbase.zookeeper.property.clientPort", "2181");
        configuration.set("hbase.zookeeper.quorum", "server201");
        Connection connection = ConnectionFactory.createConnection(configuration);
        log.info("测试连接："+connection);
        Admin admin = connection.getAdmin();
        NamespaceDescriptor[] ns = admin.listNamespaceDescriptors();
        log.info("命名空间个数："+ns.length);
        for(NamespaceDescriptor n:ns){
            System.out.println("命名空间："+n.getName());
        }
        connection.close();
    }
}
